package cn.edu.just.firstjavaapp.l8;

public class Rectangle implements Relatable{
    int width;  //宽
    int height;

    public Rectangle() {


        this(10,10);
    }

    public Rectangle(int width, int heigt) {
        this.width = width;
        this.height = heigt;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeigt() {
        return height;
    }

    public void setHeigt(int heigt) {
        this.height = heigt;
    }

    public void print(){
        System.out.println("Rectangle{width="
                +width+",height="+height
                +",area:"+getArea()+"}");
    }

    public int getArea(){
        return width*height;
    }

    @Override
    public int isLargerThan(Relatable other) {

        Rectangle otherRect=null;
        if(other instanceof Rectangle) {
            otherRect = (Rectangle) other;
        }
        return this.getArea() -otherRect.getArea();
    }
}
